package com.holly.unit.bpmn.activiti.context;

import cn.hutool.extra.spring.SpringUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.holly.unit.bpmn.activiti.ext.*;
import org.activiti.engine.*;

/**
 * 类描述: Activiti工作流操作上下文
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/1/27 15:55
 */
public class ActivitiContext {

    /**
     * RepositoryService 提供一系列操作流程定义的方法
     *
     * @author holly
     * @date 2020/10/17 14:30
     */
    public static RepositoryService repositoryService() {
        return SpringUtil.getBean(RepositoryService.class);
    }


    /***
     * HistoryService 提供一系列查询历史流程实例、历史变量、历史任务的方法
     * @return
     */
    public static HistoryService historyService() {
        return SpringUtil.getBean(HistoryService.class);
    }


    /***
     * RuntimeService 提供一系列操作流程实例的方法
     * @return
     */
    public static RuntimeService runtimeService() {
        return SpringUtil.getBean(RuntimeService.class);
    }


    /***
     * TaskService 提供一系列操作任务的方法，例如任务的完成、挂起、激活、添加处理人、认领、删除等操作
     * @return
     */
    public static TaskService taskService() {
        return SpringUtil.getBean(TaskService.class);
    }

    /***
     * IdentityService 提供一系列操作用户或组的方法
     * @return
     */
    public static IdentityService identityService() {
        return SpringUtil.getBean(IdentityService.class);
    }


    public static ManagementService managementService() {
        return SpringUtil.getBean(ManagementService.class);
    }

    /***
     * ProcessEngineConfiguration 该抽象类实现了EngineServices接口，提供了一系列创建流程配置类ProcessEngineConfiguration
     * 实例对象的方法
     * @return
     */
    public static ProcessEngineConfiguration processEngineConfiguration() {
        return SpringUtil.getBean(ProcessEngineConfiguration.class);
    }

    public static ObjectMapper objectMapper() {
        return SpringUtil.getBean(ObjectMapper.class);
    }


    /***
     * 流程定义扩展类
     * @return
     */
    public static ActivitiZProcessService zProcessService() {
        return SpringUtil.getBean(ActivitiZProcessService.class);
    }

    /***
     * 流程节点扩展类
     * @return
     */
    public static ActivitiZNodeService zNodeService() {
        return SpringUtil.getBean(ActivitiZNodeService.class);
    }

    /***
     * 流程业务扩展类
     * @return
     */
    public static ActivitiZBusinessService zBusinessService() {
        return SpringUtil.getBean(ActivitiZBusinessService.class);
    }

    /***
     * 流程消息扩展类
     * @return
     */
    public static ActivitiZNewsTemplateService zNewsTemplateService() {
        return SpringUtil.getBean(ActivitiZNewsTemplateService.class);
    }

    /***
     * 入口管理扩展类
     * @return
     */
    public static ActEntranceServiceImpl actEntranceService() {
        return SpringUtil.getBean(ActEntranceServiceImpl.class);
    }

    /***
     * 表单字段权限控制类
     * @return
     */
    public static ActivitiZNodeAuthService zNodeAuthService() {
        return SpringUtil.getBean(ActivitiZNodeAuthService.class);
    }

    /***
     * 流程定义表单设置控制类
     * @return
     */
    public static ActFromService actFromService() {
        return SpringUtil.getBean(ActFromService.class);
    }

    /***
     * 流程表达式设置控制类
     * @return
     */
    public static ActiviExpressionService activiNodeService() {
        return SpringUtil.getBean(ActiviExpressionService.class);
    }

    /***
     * 流程按钮设置控制类
     * @return
     */
    public static ActivitiZButtonService activiButtonService() {
        return SpringUtil.getBean(ActivitiZButtonService.class);
    }
}
